Skip to main content

3.1- Multiple Neurons — Vector and Matrix Form

Suppose we have 2 neurons and 3 inputs. Each neuron receives the same inputs, but has its own weights and bias.

Neuron 1Neuron 2
y1=w11x1+w12x2+w13x3+b1\boxed{y_1=w_{11}x_1+w_{12}x_2+w_{13}x_3+b_1}y2=w21x1+w22x2+w23x3+b2\boxed{y_2=w_{21}x_1+w_{22}x_2+w_{23}x_3+b_2}

Vector Form​

Put the two outputs together:

[y1y2]=[w11x1+w12x2+w13x3+b1w21x1+w22x2+w23x3+b2]\boxed{ \begin{bmatrix} y_1\\ y_2 \end{bmatrix} = \begin{bmatrix} w_{11}x_1+w_{12}x_2+w_{13}x_3+b_1\\ w_{21}x_1+w_{22}x_2+w_{23}x_3+b_2 \end{bmatrix}}

Matrix Form​

Collect all the weights into a matrix:

W=[w11w12w13w21w22w23]W= \begin{bmatrix} w_{11}&w_{12}&w_{13}\\ w_{21}&w_{22}&w_{23} \end{bmatrix}

Inputs:

x=[x1x2x3]x= \begin{bmatrix} x_1\\ x_2\\ x_3 \end{bmatrix}

Biases:

b=[b1b2]b= \begin{bmatrix} b_1\\ b_2 \end{bmatrix}

Expanded:

[y1y2]=[w11w12w13w21w22w23][x1x2x3]+[b1b2]\boxed{ \begin{bmatrix} y_1\\ y_2 \end{bmatrix} = \begin{bmatrix} w_{11}&w_{12}&w_{13}\\ w_{21}&w_{22}&w_{23} \end{bmatrix} \begin{bmatrix} x_1\\ x_2\\ x_3 \end{bmatrix} + \begin{bmatrix} b_1\\ b_2 \end{bmatrix}}

Example​

Suppose we have 2 neurons and 3 inputs.

Inputs and Parameters​

weight 1weight 2weight 3bias
Neuron 11231
Neuron 22122
inputx1x2x3
value234

Expanded Form​

Neuron 1​

NeuronNeuron 1
1y1=w11x1+w12x2+w13x3+b1y_1=w_{11}x_1+w_{12}x_2+w_{13}x_3+b_1y2=w21x1+w22x2+w23x3+b2y_2=w_{21}x_1+w_{22}x_2+w_{23}x_3+b_2
2y1=(1)(2)+(2)(3)+(3)(4)+1y_1=(1)(2)+(2)(3)+(3)(4)+1y2=(2)(2)+(1)(3)+(2)(4)+2y_2=(2)(2)+(1)(3)+(2)(4)+2
3y1=21\boxed{y_1=21}y2=17\boxed{y_2=17}
Therefore:
y=[21 and 17]\boxed{ y= \begin{bmatrix} 21 \ and \ 17 \end{bmatrix}}